<h2><a href="<?=site_url('companies/view/'.$company->id);?>"><?=$company->company_name;?></a> &ndash; <?=$job->job_title;?></h2>

<h2><a href="<?=site_url('company/'.$company->company_name);?>"><?=$company->company_name;?></a> &ndash; <?=$job->job_title;?></h2> 

<div class="block tabs spaces">
	<div class="hd">
		<ul>
			<li><a href="<?=site_url('jobs/showUpdates/'.$job->id);?>">Updates</a></li>
			<li><a href="<?=site_url('jobs/schedule/'.$job->id);?>">Schedule</a></li>
			<li><a href="<?=site_url('jobs/view/'.$job->id);?>">Job Information</a></li>
			<?php if ($permissions->createinvoice):?><li><a href="<?=site_url('jobs/generateInvoice/'.$job->id);?>">Billing</a></li><?php endif;?>
			<li>Job Setup</li>
		</ul>
		<div class="clear"></div>
	</div>
	<div class="bd">

	<p class="totalTime"><span>Progress:</span> <?php if ($totaltime > 0 && $allocatedtime > 0) echo number_format(($totaltime / $allocatedtime )*100, 0).'%'; else echo '--';?> <?php if ($permissions->showtime):?><span>Allocated:</span> <?=$allocatedtime;?>hrs <span>Spent:</span> <?=$totaltime;?>hrs <span class="right">Yours:</span> <?=$usertime;?>hrs<?php endif;?></p>
	dsd

	<?php if ($assigned_users):?>

	<table id="assignees" class="">
	<thead>
		<tr>
			<th class="name">Name</th>
			<th class="assignments">Assignments</th>
		</tr>
	</thead>
	
	<tbody>
			<?php $current_user = 0;?>
		
			<?php foreach ($assigned_users as $key => $user):?>
				
				<?php if ($user->id !== $current_user):?>
				
				<?php if ($key > 0):?></td></tr><?php endif;?>
				
				<tr>
					<td class="name">
						<div class="gravatar <?php if (!$user->active) echo 'inactive';?>"><a href="<?=site_url('users/modify/'.$user->id);?>"><img src="<?="http://www.gravatar.com/avatar.php?size=45&default=".urlencode('/assets/default/images/defaultperson.png')."&gravatar_id=".md5(trim($user->emailaddress));?>" width="45" height="45" /></a></div>
						<div class="name"><?=$user->firstname;?> <?=$user->lastname;?></div>
					</td>
					<td class="assignments">
				<?php $current_user = $user->id; endif;?>
						<?php if ($user->task):?>
							<span><?=$user->task->activity_title;?> <a class="buttonisedTight" href="<?=site_url('jobs/unassignUser/'.$user->id.'/'.$job->id.'/'.$user->department->id.'/'.$user->task->id);?>">Remove</a></span>
						<?php elseif ($user->department):?>
							
							<span><?=$user->department->centertitle;?> <a class="buttonisedTight" href="<?=site_url('jobs/unassignUser/'.$user->id.'/'.$job->id.'/'.$user->department->id);?>">Remove</a></span>
						<?php else:?>
							<span class="last">Job <a class="buttonisedTight" href="<?=site_url('jobs/unassignUser/'.$user->id.'/'.$job->id);?>">Remove</a></span>
						<?php endif;?>
			<?php endforeach;?>
					</td>
				</tr>
	</tbody>
</table>

<?php else:?>
	<p>Nobody is assigned to this job. Use the form on the right to start assigning people.</p>
<?php endif;?>

</div></div></div></div></div>


<div class="sidecolumn">
	<h2>User Assignment</h2>
	<?=form_open('jobs/assignUser', array('class' => 'formhelper userassignment'));?>
	<h3>Assign users to</h3>
	<fieldset class="marginbottom">
		<label><input type="radio" name="assignto" value="general" checked="checked" /> This Job </label>
	
		<?php if ($departments):?>
		<label><input type="radio" name="assignto" value="department" /> A Department</label>
			<select name="department"><?php foreach($departments as $department):?>
				<option value="<?=$department->id;?>"><?=$department->centertitle;?></option>
			<?php endforeach;?></select>
	
		<?php endif;?>
	
		<?php if ($hastasks):?>
			<label><input type="radio" name="assignto" value="task" /> A Task</label>
				<select name="task">
					<?php foreach($departments as $department):?>
						<?php if ($department->tasks):?>
						<optgroup label="<?=$department->centertitle;?>">
							<?php foreach($department->tasks as $task):?>
								<option value="<?=$task->id;?>"><?=$task->activity_title;?></option>
							<?php endforeach;?>
						</optgroup>
						<?php endif;?>
					<?php endforeach;?>
				</select>
		<?php endif;?>
	</fieldset>

	<?php if ($users):?>
	<h3>Choose you weapons</h3>
			<?php foreach ($users as $user):?>
			<label><input type="checkbox" name="userid[]" value="<?=$user->id;?>" id="user-<?=$user->id;?>" /> <?=$user->firstname;?> <?=$user->lastname;?></label>
			<?php endforeach;?>
	<?php endif;?>
	
	<input type="submit" class="submit" name="submit" value="Assign" />
	<input type="hidden" name="jobid" value="<?=$job->id;?>" />
	
	
	<?=form_close();?>
</div>